using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;

public class gameloader {
    public static gameloader Instance = new gameloader();
    string filename = "script.txt";
    public gameloader()
    { 
    }


    internal Dictionary<int, string> getCmds(out int indexmax)
    {
        Dictionary<int, string> cmds = new Dictionary<int, string>();
        StreamReader sr = new StreamReader(filename);
        string linetxt = string.Empty;
        int lineindex = 1;
        int startindex = 1;
        bool append = false;
        while (!sr.EndOfStream)
        {
            if (!append)
            {
                linetxt = sr.ReadLine();
                startindex = lineindex;
            }
            else
            {
                linetxt += sr.ReadLine();
                append = false;
            }

            int i = linetxt.IndexOf('#');
            if (i >= 0)
                linetxt = linetxt.Remove(i);
            linetxt = linetxt.Trim();
            if (linetxt.EndsWith("/"))
            {
                append = true;
                linetxt = linetxt.Remove(linetxt.LastIndexOf('/'));
            }
            else
                cmds.Add(startindex, linetxt);
            lineindex++;
        }
        sr.Close();
        indexmax = startindex;
        return cmds;
    }


    

}
